//
//  ICTestCell.m
//  iComeSDK_Example
//
//  Created by zhangrongwu on 2018/1/23.
//  Copyright © 2018年 zhangrongwu. All rights reserved.
//

#import "ICTestCell.h"
#import "Masonry.h"
#import <SDWebImage/UIImageView+WebCache.h>
@interface ICTestCell()
@property (nonatomic, strong)UIImageView *headImageView;
@property (nonatomic, strong)UILabel *titleLabel;
@property (nonatomic, strong)UILabel *descLabel;
@property (nonatomic, strong)UILabel *nameLabel;

@end
@implementation ICTestCell
///////////////////////////////!!!!!涉及到写入静态库，请不要使用 make.width.and.height.mas_equalTo(50)这种写法
- (instancetype)initWithStyle:(UITableViewCellStyle)cell reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:cell reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        self.contentView.backgroundColor = [UIColor lightGrayColor];
        
//        UILabel *top = [[UILabel alloc] init];
//        [self.contentView addSubview:top];
//        [top mas_remakeConstraints:^(MASConstraintMaker *make) {
//            make.top.equalTo(self.contentView.mas_top);
//            make.left.equalTo(self.contentView.mas_left);
//            make.height.mas_equalTo(1);
//        }];
        
        self.headImageView = [[UIImageView alloc] init];
        self.headImageView.backgroundColor = [UIColor yellowColor];
        self.headImageView.layer.cornerRadius = 25;
        self.headImageView.layer.masksToBounds = YES;
        
        [self.contentView addSubview:self.headImageView];
        [self.contentView addSubview:self.nameLabel];
        [self.contentView addSubview:self.titleLabel];
        [self.contentView addSubview:self.descLabel];
        
        [self.headImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.contentView.mas_top).offset(10);
            make.left.equalTo(self.contentView.mas_left).offset(10);
            make.height.mas_equalTo(50);
            make.width.mas_equalTo(50);
        }];
        
        [self.nameLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.contentView.mas_top).offset(10);
            make.left.equalTo(self.headImageView.mas_right).offset(10);
            make.height.mas_equalTo(50);
        }];

        [self.titleLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.nameLabel.mas_bottom).offset(10);
            make.left.equalTo(self.nameLabel.mas_right).offset(10);
        }];

        [self.descLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.titleLabel.mas_bottom).offset(10);
            make.left.equalTo(self.titleLabel.mas_left);
            make.height.mas_equalTo(50);
        }];
        
        
        [self.bottomLine mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.descLabel.mas_bottom);
            make.right.and.left.mas_equalTo(self.contentView);
            make.height.mas_equalTo(1);
            make.bottom.mas_equalTo(self.contentView.mas_bottom);
        }];
        
            }
    return self;
}

-(UILabel *)titleLabel {
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc] init];
        _titleLabel.font = [UIFont systemFontOfSize:14];
        _titleLabel.textColor = [UIColor redColor];
    }
    return _titleLabel;
}

-(UILabel *)descLabel {
    if (!_descLabel) {
        _descLabel = [[UILabel alloc] init];
        _descLabel.font = [UIFont systemFontOfSize:12];
        _descLabel.textColor = [UIColor redColor];
    }
    return _descLabel;
}

-(UILabel *)nameLabel {
    if (!_nameLabel) {
        _nameLabel = [[UILabel alloc] init];
        _nameLabel.font = [UIFont systemFontOfSize:12];
        _nameLabel.textColor = [UIColor redColor];
    }
    return _nameLabel;
}

- (void)messageBtnClick {
    NSLog(@"测试");
}

-(void)setData:(id)data {
    [super setData:data];
    NSLog(@"%@", data);
//    NSString *eId = data[@"fr"];// 自己去拼接成url
//    [self.headImageView sd_setImageWithURL:[NSURL URLWithString:eId]];
    if ([data[@"type"] isEqualToString:@"1000"]) {
//        self.headImageView.backgroundColor = UIColor.cyanColor;
        self.nameLabel.text = data[@"nName"];
        self.titleLabel.text = @"这是一个测试数据";
        self.descLabel.text = data[@"data"];
    }
}



@end
